//
//  AlongDefanceDelayViewController.m
//  LFCWarmSystem
//
//  Created by Kill on 16/4/29.
//  Copyright © 2016年 李福才. All rights reserved.
//

#import "AlongDefanceDelayViewController.h"

@interface AlongDefanceDelayViewController ()<MFMessageComposeViewControllerDelegate>

@end

@implementation AlongDefanceDelayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.lblHeadView.text = NSLocalizedString(@"IndependentDelayTime_Sample", @"独立防区延迟时间");
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

-(void)rightAction:(id)sender{
    NSString *msgContect = [self languageMSG:@"Single zone delay time(0-300 sec):"];
    msgContect = [NSString stringWithFormat:@"%@\n%@",msgContect,self.lblTime.titleLabel.text];
    [self showSMSPicker:msgContect];
}
- (NSString *)languageMSG:(NSString*)content{
    NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"mulLan" ofType:@"plist"];
    NSDictionary *data = [[NSDictionary alloc] initWithContentsOfFile:plistPath];
    NSString * str = @"";
    if ((str = (NSString *)[data objectForKey:[NSString stringWithFormat:@"CIndependentDelayTimeSMS_%@ ",self.modelPhone.language]])) {
        content = str;
    }
    return [[content componentsSeparatedByString:@"\\r"] firstObject];
}
#pragma mark-Send Message
-(void)showSMSPicker:(NSString *)MSGContent{
    Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));
    if (messageClass != nil) {
        // Check whether the current device is configured for sending SMS messages
        if ([messageClass canSendText]) {
            MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
            picker.recipients = [NSArray arrayWithObjects:self.modelPhone.phoneNumber, nil];
            picker.messageComposeDelegate = self;
            picker.body = MSGContent;
            [self presentViewController:picker animated:YES completion:^{
            }];
        }
        else {
            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:NSLocalizedString(@"DeviceCantMSG", @"设备没有短信功能")  message:nil delegate:nil cancelButtonTitle:NSLocalizedString(@"Close_Sample", @"  关闭") otherButtonTitles: nil];
            [alert show];
        }
    }
    else {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:NSLocalizedString(@"VersionProblem", @"iOS版本过低,iOS4.0以上才支持程序内发送短信") message:nil delegate:nil cancelButtonTitle:NSLocalizedString(@"Close_Sample", @"  关闭") otherButtonTitles: nil];
        [alert show];
    }
}

//#pragma mark-MFMessageComposeViewControllerDelegate
//- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
//    
//    switch (result)
//    {
//        case MessageComposeResultCancelled:
//            NSLog(@"Result: SMS sending canceled");
//            break;
//        case MessageComposeResultSent:
//            NSLog(@"Result: SMS sent");
//            break;
//        case MessageComposeResultFailed:{
//            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:NSLocalizedString(@"SendMSGFail", @"短信发送失败")  message:nil delegate:nil cancelButtonTitle:NSLocalizedString(@"Close_Sample", @"  关闭") otherButtonTitles: nil];
//            [alert show];
//        }
//            break;
//        default:
//            NSLog(@"Result: SMS not sent");
//            break;
//    }
//    [self dismissViewControllerAnimated:YES completion:^{}];
//}
@end
